#include "asset.h"

namespace teflon
{
    std::string get_asset_path(const char* file_name)
    {
    #if __APPLE__
        std::string root("/Users/liyu/Desktop/workspace/nextengine/gingerale/resources/");
    #else
        std::string root("D:\\projects\\gingerale\\resources\\");
    #endif
        return root + file_name;
    }

    std::shared_ptr<AssetManager> AssetManager::g_manager = nullptr;

    std::shared_ptr<AssetManager> AssetManager::GetAssetManager()
    {
        if (g_manager != nullptr)
        {
            g_manager = std::make_shared<AssetManager>();
        }
        return g_manager;
    }

    std::shared_ptr<Texture2D> AssetManager::LoadTexture(const std::string& texture_name)
    {
        std::string abs_path = get_asset_path(texture_name.c_str());
        auto texture = Texture2D::fromImageFile(abs_path);
        texture_map.insert(std::make_pair(texture_name, texture));
        return texture;
    }

    std::shared_ptr<ShaderProgram> AssetManager::LoadShader(const std::string& shader_name)
    {
        // scan all shader source files with the name,
        // shader type is provided with the file postfix.

        return nullptr;
    }

}

